home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / admin / xinetd.2 / xinetd / xinetd.2.1.7-linux.4 / libs / src / xlog / impl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-25  |  2.8 KB  |  107 lines

  1. /*
  2.  * (c) Copyright 1992, 1993 by Panagiotis Tsirigotis
  3.  * All rights reserved.  The file named COPYRIGHT specifies the terms 
  4.  * and conditions for redistribution.
  5.  */
  6.  
  7.  
  8. /*
  9.  * $Id: impl.h,v 2.1 1993/05/06 07:40:05 panos Exp $
  10.  */
  11.  
  12.  
  13. #define DEFINE_LINK_TYPE( type, name )        struct { type *next, *prev ; } name
  14.  
  15.  
  16. #define NEXT( obj, field )                        (obj)->field.next
  17. #define PREV( obj, field )                        (obj)->field.prev
  18.  
  19. #define INIT_LINKS( obj, field )                                                            \
  20.                     {                                                                                \
  21.                         NEXT( obj, field ) = obj ;                                            \
  22.                         PREV( obj, field ) = obj ;                                            \
  23.                     }
  24.  
  25. /*
  26.  * Link new object after object using the specified field
  27.  */
  28. #define LINK( obj, new_obj, field )                                                        \
  29.             {                                                                                        \
  30.                 NEXT( new_obj, field ) = NEXT( obj, field ) ;                        \
  31.                 PREV( new_obj, field ) = obj ;                                            \
  32.                 NEXT( obj, field ) = new_obj ;                                            \
  33.                 PREV( NEXT( obj, field ), field ) = new_obj ;                        \
  34.             }
  35.  
  36. #define UNLINK( obj, field )                                                                \
  37.                     {                                                                                \
  38.                         NEXT( PREV( obj, field ), field ) = NEXT( obj, field ) ;    \
  39.                         PREV( NEXT( obj, field ), field ) = PREV( obj, field ) ;    \
  40.                     }
  41.  
  42.  
  43. /*
  44.  * xlog linking:
  45.  *     When xlog1 is linked to xlog2 (i.e. errors on xlog1 are reported to 
  46.  *        xlog2) we use the xl_clients field on xlog2 and the xl_other_users 
  47.  *        field on xlog1
  48.  */
  49. struct xlog
  50. {
  51.     xlog_e             xl_type ;
  52.     char                 *xl_id ;
  53.     int                 xl_flags ;
  54.     void                 (*xl_callback)() ;
  55.     void                 *xl_callback_arg ;
  56.     struct xlog     *xl_use ;                /* xlog we report errors to         */
  57.     struct xlog     *xl_clients ;            /* linked list of xlogs that use */
  58.                                                     /* this xlog to report errors     */
  59.     DEFINE_LINK_TYPE( struct xlog, xl_other_users ) ;
  60.     struct xlog_ops
  61.     {
  62.         int     (*init)        __ARGS( ( struct xlog *, va_list ) ) ;
  63.         void    (*fini)         __ARGS( ( struct xlog * ) ) ;
  64.         int    (*write)        __ARGS( ( struct xlog *, char *, int, int, va_list ) ) ;
  65.         int    (*control)    __ARGS( ( struct xlog *, xlog_cmd_e, va_list ) ) ;
  66.         int    (*parms)     __ARGS( ( va_list ) ) ;
  67.     }                     *xl_ops ;
  68.     void                 *xl_data ;
  69. } ;
  70.  
  71. #define XL_INIT( xp, ap )                    (*(xp)->xl_ops->init)( (xp), (ap) )
  72. #define XL_FINI( xp )                        (*(xp)->xl_ops->fini)( xp )
  73. #define XL_WRITE( xp, buf, size, flags, ap ) \
  74.                     (*(xp)->xl_ops->write)( (xp), (buf), (size), (flags), (ap ) )
  75. #define XL_CONTROL( xp, cmd, ap ) \
  76.                     (*(xp)->xl_ops->control)( (xp), (cmd), (ap) )
  77.  
  78. typedef struct xlog xlog_s ;
  79.  
  80. typedef void (*voidfunc)() ;
  81. typedef int bool_int ;
  82.  
  83. #define XP( p )                        ((struct xlog *)(p))
  84.  
  85. #define XLOG_NULL                        XP( NULL )
  86.  
  87. #ifndef FALSE
  88. #define FALSE        0
  89. #define TRUE        1
  90. #endif
  91.  
  92. #ifndef NULL
  93. #define NULL        0
  94. #endif
  95.  
  96. #define NEW( type )                    (type *) malloc( sizeof( type ) )
  97. #define FREE( p )                        (void) free( (char *)p )
  98.  
  99. #define PRIVATE        static
  100.  
  101. char *__xlog_add_errno() ;
  102. char *__xlog_explain_errno() ;
  103. char *__xlog_new_string() ;
  104.  
  105. char *malloc() ;
  106.  
  107.